package com.gateway.bootstrap.listener;

import com.gateway.springboot.starter.gateway.route.CommonRouteDataSubscriber;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

/**
 * @program: api-gateway
 * @description:
 * @author: YuKai Fan
 * @create: 2025/2/21 16:28
 **/
public class GatewayRouteInitListener implements ApplicationListener<ContextRefreshedEvent> {

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        ApplicationContext applicationContext = event.getApplicationContext();
        CommonRouteDataSubscriber subscriber = applicationContext.getBean(CommonRouteDataSubscriber.class);
        subscriber.refresh();
        subscriber.refreshFilter();
        subscriber.refreshPredicate();
    }
}
